<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        p.red {
            color: red;
        }
    </style>
</head>
<body>
    <p>只有p没有类不会变红</p>
    <div class="red">只有类没有p不会变红</div>
    <p class="red">类和p都有会变红</p>
</body>
</html>